package service;

import entity.UserEntity;
import mapper.UserMapper;

/**
 * @author HuangJH
 * @create 2023-11-30-10:45
 */
public class UserService {

    private UserMapper userMapper = new UserMapper();

    /**
     * 注册
     * @param identityNum
     * @param account
     * @param password
     * @return
     */
    public boolean registeredUser(int identityNum, String account, String password) {
        // 构建实体
        UserEntity userEntity = new UserEntity();
        userEntity.setIdentity(identityNum);
        userEntity.setAccount(account);
        userEntity.setPassword(password);
        return userMapper.addUser(userEntity);
    }

    /**
     * 登录
     * @param identityNum
     * @param account
     * @param password
     * @return
     */
    public UserEntity login(int identityNum, String account, String password) {
        // 构建实体
        UserEntity userEntity = new UserEntity();
        userEntity.setIdentity(identityNum);
        userEntity.setAccount(account);
        userEntity.setPassword(password);
        return userMapper.login(userEntity);
    }
}
